package TUILayer;
import java.util.Scanner;
import ControlLayer.*;



public class LoanUI
{
    private LoanCtr loanCtr;

   
    public LoanUI()
    {loanCtr=new LoanCtr();
    }
     public void start()
    {
       
        loanMenu();
    }
      public void loanMenu()
       {   
        boolean exit = false;
        while(!exit)
        {
           
            int choice =   writeLoanMenu();
            if (choice == 1)
            {
                borrowDVD();
            }
            else{if(choice == 2){
                   returnDVD();
                }
                
                            else{
                                exit = true;System.out.println("\f");
                               }//end else
                        }//end else
    }}
    private int writeLoanMenu()
    {
           // creates an object keyboard to read data from the keyboard
            Scanner keyboard = new Scanner(System.in);
            System.out.println(" *** DVD Menu ***");
            System.out.println(" (1) BorrowDVD");
            System.out.println(" (2) ReturnDVD");
            System.out.println(" (3) Return");
            System.out.print("\n Make your choice: ");
            
            int choice = keyboard.nextInt();
            return choice;
    }
    private int inputDVDNo()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD number: ");
        int no = keyboard.nextInt();
        return no;
    }
    private int inputLoanId()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type Loan Id: ");
        int id = keyboard.nextInt();
        return id;
    }    
      private String inputLoanBorrow()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type Loan borrow date: ");
        String borrowDate = keyboard.nextLine();
        return borrowDate;
    }    
    private String inputLoanPeriod()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type Loan Id: ");
        String period = keyboard.nextLine();
        return period;
    }  
     private String inputPersonName()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type Person that wants to borrow: ");
        String name = keyboard.nextLine();
        return name;
    }  
     private void borrowDVD()
    {int no=inputDVDNo();
     int id=inputLoanId();
     String borrowDate=inputLoanBorrow();
     String period=inputLoanPeriod();
     String name=inputPersonName();
     loanCtr.borrowDVD(no,id,borrowDate,period,name);
    }  
    private void returnDVD()
    {int no=inputDVDNo();
     loanCtr.returnDVD(no);}
}
